package com.example.hosptial.model.enity;

import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import lombok.Data;

import java.util.List;

@Data
@Entity
@Table(name = "doctor")
public class Doctor {
    @Id
    @Column(length = 20)
    private String doctorId;

    @NotBlank(message = "医生姓名不能为空")
    @Size(max = 50, message = "医生姓名长度不能超过50个字符")
    @Column(nullable = false, length = 50)
    private String doctorName;

    @Pattern(regexp = "^[男女]$", message = "性别只能是男或女")
    @Column(length = 1)
    private String doctorGender;

    @Min(value = 1, message = "年龄必须大于0")
    private Integer doctorAge;

    @NotBlank(message = "密码不能为空")
    @Size(min = 6, max = 100, message = "密码长度必须在6-100个字符之间")
    @Column(nullable = false, length = 100)
    private String doctorPassword;

    @NotBlank(message = "身份证号不能为空")
    @Pattern(regexp = "^\\d{17}[0-9X]$", message = "身份证号格式不正确")
    @Column(unique = true, nullable = false, length = 18)
    private String doctorIdCard;

    @Pattern(regexp = "^\\d{1,20}$", message = "电话号码格式不正确")
    @Column(length = 20)
    private String doctorPhone;

    @ManyToOne
    @JoinColumn(name = "deptId")
    private Department department;

    @OneToMany(mappedBy = "doctor")
    private List<Patient> patients;
} 